python avoid floating point errors